# # Variables
# GOCMD=go
# GOBUILD=$(GOCMD) build
# GOCLEAN=$(GOCMD) clean
# GOTEST=$(GOCMD) test
# GOGET=$(GOCMD) get

# # Targets
# BINARY_NAME=myapp
# MAIN_FILE=cmd/main.go
# BUILD_OUTPUT=bin/$(BINARY_NAME)

# all: deps build
# build:
#     $(GOBUILD) -o $(BUILD_OUTPUT) -v $(MAIN_FILE)
# clean:
#     $(GOCLEAN)
#     rm -f $(BUILD_OUTPUT)
# test:
#     $(GOTEST) -v ./...
# deps:
#     $(GOGET)

# .PHONY: all build clean test deps


# # 使用这个来进行通配处理
# # 如果必须使用文件列表可以这样
# # target := a.c\
# #           b.c\
# #           c.c
# # 
# OBJECTS := $(wildcard *.o)

# main: $(OBJECTS)
#     gcc -o main $(OBJECTS)

# # 先通配在排除
# # ALL_FILES := $(wildcard *.c)
# # EXCLUDED_FILES := file2.c file3.c
# # INCLUDED_FILES := $(filter-out $(EXCLUDED_FILES),$(ALL_FILES))

# # 递归添加整个目录
# SOURCES := $(shell find src -name '*.c')  # 递归查找src目录下的所有.c文件，可以结合 | grep -v -e "a.x" -e "b.c"进行排除
#################################

###
## 万能makefile
# CC = gcc
# CFLAGS = -Wall

# SRCS = $(wildcard *.c)
# OBJS = $(SRCS:.c=.o)
# EXEC = myprogram

# all: $(EXEC)

# $(EXEC): $(OBJS)
#     $(CC) $(OBJS) -o $(EXEC)

# %.o: %.c
#     $(CC) $(CFLAGS) -c $< -o $@

# clean:
#     rm -f $(OBJS) $(EXEC)
###


all: 
	@echo "doing make all"
	@make embed_web 
	@make web_xrpc
	@echo "finish doing make all"

EMBED_WEB_SRC_LIST := $(shell find embed_web -name '*.go')   
bin/embed_web: $(EMBED_WEB_SRC_LIST)  # $(TARGET): $(SRC)
	go build -o bin/embed_web embed_web/main/embed_web_main.go
.PHONY: embed_web                     # 支持直接：make embed_web
embed_web: bin/embed_web

bin/web_xrpc: web_xrpc_main.go
	go build -o bin/web_xrpc web_xrpc_main.go 2>&1
.PHONY: web_xrpc
web_xrpc: bin/web_xrpc

.PHONY: clear
clear:
	@echo "doing clear: \n\tclear_embed_web \n\tclear_web_xrpc"
	@make clear_embed_web 
	@echo "finish clear_embed_web"
	@make clear_web_xrpc
	@echo "finish clear_web_xrpc"
	@echo "all clear done"

.PHONY: clear_web_xrpc
clear_web_xrpc:
	rm -f bin/web_xrpc

.PHONY: clear_embed_web
clear_embed_web:
	rm -f bin/embed_web